Path Queries in Weighted Trees
نویسندگان
چکیده
We consider the problem of supporting several different path queries over a tree on n nodes, each having a weight drawn from a set of σ distinct values, where σ ≤ n. One query we support is the path median query, which asks for the median weight on a path between two given nodes. For this and the more general path selection query, we present a linear space data structure that answers queries in O(lg σ) time under the word RAM model. This greatly improves previous results on the same problem, as previous data structures achieving O(lg n) query time use O(n lg n) space, and previous linear space data structures require O(n) time to answer a query for any positive constant 2 [16]. Our linear space data structure also supports path counting queries in O(lg σ) time. This matches the result of Chazelle [8] when σ is close to n, but has better performance when σ is significantly smaller than n. Finally, the same data structure can also support path reporting queries in O(lg σ+occ lg σ) time, where occ is the size of output. In addition, we present a data structure that answers path reporting queries in O(lg σ+occ lg lg σ) time, using O(n lg lg σ) space. These are the first data structures that answer path reporting queries.
منابع مشابه
Reconstructing a Bounded-Degree Directed Tree Using Path Queries
We present a randomized algorithm for reconstructing directed rooted trees of n nodes and node degree at most d, by asking at most O(dn log n) path queries. Each path query takes as input an origin node and a target node, and answers whether there is a directed path from the origin to the target. Our algorithm is only a factor of O(d log n) from the informationtheoretic lower bound of Ω(n log n...
متن کاملIn-Memory Storage for Labeled Tree-Structured Data
In this thesis, we design in-memory data structures for labeled and weights trees, so that various types of path queries or operations can be supported with efficient query time. We assume the word RAM model with word size w, which permits random accesses to w-bit memory cells. Our data structures are space-efficient and many of them are even succinct. These succinct data structures occupy spac...
متن کاملOptimal Data Structures for Farthest-Point Queries in Cactus Networks
Consider the continuum of points on the edges of a network, i.e., a connected, undirected graph with positive edge weights. We measure the distance between these points in terms of the weighted shortest path distance, called the network distance. Within this metric space, we study farthest points and farthest distances. We introduce optimal data structures supporting queries for the farthest di...
متن کاملAdaptive Algorithms for Weighted Queries on Weighted Binary Relations and Labeled Trees
Keyword queries are extremely easy for a user to write. They have become a standard way to query for information in web search engines and most other information retrieval systems whose users are usually laypersons and might not have knowledge about the database schema or contained data. As keyword queries do not impose any structural constraints on the retrieved information, the quality of the...
متن کاملOptimal Data Structures for Farthest-Point
6 Consider the continuum of points on the edges of a network, i.e., a connected, undirected graph 7 with positive edge weights. We measure the distance between these points in terms of the weighted 8 shortest path distance, called the network distance. Within this metric space, we study farthest points 9 and farthest distances. We introduce optimal data structures supporting queries for the far...
متن کامل